<template>
  <div>
    <!-- firststart -->
    <div style="margin: 40px;margin-top: -5px;margin-bottom: 20px;">
      <div style="padding: 15px;padding-left: 30px;background-color: #fdb6a7;">
          <div style="">当前订单状态：<span style="color: #0eb0fd;">{{orderDetailList.status_name}}</span></div>
          <div style="margin-top: 5px;margin-bottom: -5px;">
              <!--<el-button  v-if="orderDetailList.status == 2 && orderDetailList.delivery_method_name !='自提'"   @click="deliverGoods(orderDetailList)" type="primary" size="mini">立即发货</el-button>
              <el-button  v-if="orderDetailList.status == 1"  :disabled="true" type="primary" size="mini">立即发货</el-button>
              <el-button v-if="orderDetailList.status == 3 && orderDetailList.delivery_method_name ==='自提'" type="success" size="mini" @click="confirmReceive(orderDetailList.id)">确认收货</el-button>

              <el-button v-if="orderDetailList.status != 6 && orderDetailList.status != 5 && orderDetailList.status != 4"
                   @click="cancelOrder(orderDetailList.id)" type="text" style="color: red;">取消订单</el-button>-->
            <el-button v-if="(orderDetailList.status == 2 || orderDetailList.status == 8) && orderDetailList.delivery_method_name !='自提'" type="success" size="mini" @click="deliverGoods(orderDetailList)">发货</el-button>
            <el-button v-if="(orderDetailList.status == 3 || orderDetailList.status == 8) && orderDetailList.delivery_method_name =='自提'" type="success" size="mini" @click="confirmReceive(orderDetailList.id)">确认收货</el-button>
            <el-button style="margin-top: 5px" type="primary" size="mini" v-if="orderDetailList.status == 5" @click="showRefundDialog(orderDetailList,'apply')">处理申请</el-button>
            <el-button style="margin-top: 5px" type="primary" size="mini" v-else-if="!([5,6].includes(orderDetailList.status))&&orderDetailList.is_pay==1" @click="showRefundDialog(orderDetailList,'refund')">退款</el-button>
          </div>
      </div>
    </div>
    <div class="wrapBetween">
      <!-- 左边 -->
      <div class="contenLeft">
        <div class="title">买家信息</div>
        <div class="detailCss">
          <span class="detailSpan">收货姓名</span>
          <span v-if="address_info.consignee!='' ">{{address_info.consignee}}</span>
          <span v-else>未填写</span>
        </div>
        <div class="detailCss">
          <span class="detailSpan">手机号码</span>
          <span>{{address_info.phone}}</span>
        </div>
        <div class="detailCss">
          <span class="detailSpan">收货地址</span>
          <span v-if="address_info.province!=''">
            <span>{{address_info.province}}/{{address_info.city}}/{{address_info.area}}/{{address_info.address}}</span>
          </span>
          <span v-else>
            地址未填写
          </span>
        </div>
        <div class="title" style="margin-top: 20px;">物流信息</div>
        <div  v-if="orderDetailList.delivery_method_name !='自提'">
          <div class="detailCss">
            <span class="detailSpan">物流公司</span>
            <span v-if="orderDetailList.express!=null">{{orderDetailList.express}}</span>
            <span v-else>未填写</span>
          </div>
          <div class="detailCss">
            <span class="detailSpan">运单号</span>
            <span  class="wrapSpan" v-if="orderDetailList.express_num!=null">{{orderDetailList.express_num}}</span>
            <span v-else>未填写</span>
          </div>
        </div>
        <div class="detailCss">
          <span class="detailSpan">配送方式</span>
          <span>{{orderDetailList.delivery_method_name}}</span>
        </div>
        <div class="detailCss" v-if="orderDetailList.delivery_method == 'express_delivery' || orderDetailList.delivery_method == 'instant_delivery' ">
          <span class="detailSpan">运费</span>
          <span>{{orderDetailList.delivery_fee}}</span>
        </div>
        <div class="detailCss" v-if="orderDetailList.delivery_method_name !='自提'">
          <span class="detailSpan">发货时间</span>
          <span v-if="orderDetailList.express_time!=null">{{orderDetailList.express_time}}</span>
          <span v-else>尚未发货</span>
        </div>
        <div class="detailCss" v-if="orderDetailList.delivery_method_name =='自提'">
          <span class="detailSpan">收货时间</span>
          <span v-if="orderDetailList.receive_time!=null">{{orderDetailList.receive_time}}</span>
          <span v-else>尚未收货</span>
        </div>

      </div>
      <!-- 右边 -->
      <div class="contenLeft">
        <div class="title">订单信息</div>
         <div class="detailCss">
           <span class="detailSpan">订单号</span>
           <span class="wrapSpan">{{orderDetailList.order_num}}</span>
         </div>
         <div class="detailCss">
           <span class="detailSpan">订单状态</span>
           <span>{{orderDetailList.status_name}}</span>
         </div>
         <!-- <div class="detailCss">
           <span class="detailSpan">下单用户</span>
           <span>{{user_info.nickname}}</span>
         </div> -->
        <!-- <div class="detailCss">
           <span class="detailSpan">实付</span>
           <span>{{orderDetailList.pay_amount}}</span>
         </div> -->
        <!-- <div class="detailCss">
           <span class="detailSpan">优惠金额</span>
           <span>{{orderDetailList.coupon_reduce_price}}</span>
         </div> -->
         <div class="detailCss">
           <span class="detailSpan">所属门店</span>
           <span>{{orderDetailList.merchant_name}}</span>
         </div>
        <!-- <div class="detailCss">
           <span class="detailSpan">支付方式</span>
           <span v-if="orderDetailList.pay_way!=null">{{orderDetailList.pay_way}}</span>
           <span v-else>未支付</span>
         </div> -->
         <div class="detailCss">
           <span class="detailSpan">订单备注</span>
           <span v-if="orderDetailList.remark!=''">{{orderDetailList.remark}}</span>
           <span v-else>暂无备注</span>
         </div>
         <div class="detailCss">
           <span class="detailSpan">支付时间</span>
           <span v-if="orderDetailList.pay_time!=null">{{orderDetailList.pay_time}}</span>
           <span v-else>未支付</span>
         </div>
         <div class="detailCss" v-if="orderDetailList.status==6">
           <span class="detailSpan">取消时间</span>
           <span v-if="orderDetailList.updated_at!=null">{{
        orderDetailList.updated_at}}</span>
        </div>
        <div class="detailCss">
          <span class="detailSpan">创建时间</span>
          <span>{{orderDetailList.created_at}}</span>
        </div>
        <!--<div style="margin-top: 15px" v-if="orderDetailList.refund_info&&orderDetailList.refund_info.length>0">
          <div class="title">退款信息</div>
          <div v-for="(item,index) in orderDetailList.refund_info" :key="index">
            <div class="detailCss">
              <span class="detailSpan">退款金额</span>
              <span class="msg">{{item.refund_amount}}</span>
            </div>
            <div class="detailCss">
              <span class="detailSpan">退款原因</span>
              <span class="msg">{{item.refund_reason}}</span>
            </div>
            <div class="detailCss">
              <span class="detailSpan">状态</span>
              <span class="msg">{{item.status}}</span>
            </div>
          </div>
        </div>-->

      </div>
    </div>
    <!-- firstend -->
    <div class="secondConten" v-if="orderDetailList.refund_info&&orderDetailList.refund_info.length>0">
      <div class="contenBottem ">
        <div class="title" style="margin-bottom: 20px;">退款信息</div>
        <el-table :data="orderDetailList.refund_info" :header-cell-style="{background:'#eef1f6',color:'#606266'}"
                  border style="width: 100%;">
          <el-table-column align="center" prop="refund_num" label="序号" />
          <el-table-column align="center" prop="refund_amount" label="已退金额" />
          <el-table-column align="center" prop="refund_reason" label="退款原因" />
          <el-table-column align="center" prop="status" label="状态" />
        </el-table>
      </div>
    </div>

    <div class="secondConten" v-if="prescriptionInfo && prescriptionInfo.user_drug_Info">
      <div class="contenBottem ">
        <div class="title" style="margin-bottom: 20px;">处方信息</div>
        <div class="prescription-status">
          <el-row v-if="prescriptionInfo.has_prescription == 0">
            <el-col :span="8">
              <span class="left">处方状态</span>
              <span class="right">{{prescriptionInfo.status}}</span>
            </el-col>
            <el-col :span="8">
              <span class="left">开方方式</span>
              <span class="right">{{'问诊开方'}}</span>
            </el-col>
            <el-col :span="8">
              <span class="left">处方单号</span>
              <span class="right">{{prescriptionInfo.perscriptionNumber}}</span>
            </el-col>
          </el-row>
          <el-row v-if="prescriptionInfo.has_prescription == 1">
            <el-col :span="8">
              <span class="left">开方方式</span>
              <span class="right">{{'上传开方'}}</span>
            </el-col>
          </el-row>
        </div>
        <div class="prescription-info">
          <el-row>
            <el-col :span="12">
              <el-row>
                <el-col class="item-left" :span="8">用药人真实姓名</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientName}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">性别</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientSex_name}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">年龄</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientAge}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">体重</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientWeight}}{{prescriptionInfo.user_drug_Info.patientWeight?'kg':''}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">手机号</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientPhone}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">身份证</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientIdcard}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">出生日期</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientBirthday}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">地址</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.patientAddress}}</el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <el-col class="item-left" :span="8">描述症状</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.diagnoseDescription}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">有无过往病史</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.pmh?prescriptionInfo.user_drug_Info.pmh:'无'}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">有无过敏史</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.amh?prescriptionInfo.user_drug_Info.amh:'无'}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">有无家族病史</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.fmh?prescriptionInfo.user_drug_Info.fmh:'无'}}</el-col>
              </el-row>
            </el-col>
            <el-col :span="12">
              <el-row>
                <el-col class="item-left" :span="8">有无妊娠哺乳</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.nurse?prescriptionInfo.user_drug_Info.nurse:'无'}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">有无肝功能异常</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.liver?prescriptionInfo.user_drug_Info.liver:'无'}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" :span="8">有无肾功能异常</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.user_drug_Info.renal?prescriptionInfo.user_drug_Info.renal:'无'}}</el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <el-col class="item-left" :span="8">此次问诊疾病信息</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.prescription_disease_list}}</el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <el-col class="item-left" :span="8">此次问诊药品信息</el-col>
                <el-col class="item-right" :span="16">{{''}}</el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <el-col class="item-left" :span="8">诊断级别</el-col>
                <el-col class="item-right" :span="16">
                  <span v-if="prescriptionInfo.diagnosticLevel==1">普通患病并已确诊</span>
                  <span v-if="prescriptionInfo.diagnosticLevel==2">慢性病并确诊</span>
                  <span v-if="prescriptionInfo.diagnosticLevel==3">尚未确诊</span>
                </el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <el-col class="item-left" :span="8">既往用药情况</el-col>
                <el-col class="item-right" :span="16">
                  <span v-if="prescriptionInfo.drugUsage==1">药物用完需要继续购买完成疗程</span>
                  <span v-if="prescriptionInfo.drugUsage==2">医生建议使用此药</span>
                </el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <el-col class="item-left" :span="8">初审医师</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.checkDoctorName}}</el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <el-col class="item-left" :span="8">复审医师</el-col>
                <el-col class="item-right" :span="16">{{prescriptionInfo.reviewDoctorName}}</el-col>
              </el-row>
              <el-row>
                <el-col class="item-left" style="height: 100px" :span="8">处方单</el-col>
                <el-col class="item-right" style="height: 100px" :span="16">
                  <el-image
                    v-for="(item,index) in prescriptionInfo.prescription_img_list" :key="index"
                    style="width: 90px; height: 90px;cursor: pointer"
                    :src="item.img_url"
                    @click="checkPrescriptionImg(prescriptionInfo.prescription_img_list)"
                    :fit="'contain'"></el-image>
                  <!--<el-button type="text" v-if="prescriptionInfo.prescription_img_list.length>0" @click="checkPrescriptionImg(prescriptionInfo.prescription_img_list)">查看</el-button>-->
                  <el-button v-if="prescriptionInfo.status==='医生拒绝开方'" style="margin-left: 20px;" type="text" @click="showManualDialog">人工处理</el-button>
                  <el-image-viewer :on-close="closeImgViewer" v-if="showViewer" :url-list="prescription_img_list"/>
                </el-col>
              </el-row>
              <el-row v-if="prescriptionInfo.has_prescription==0">
                <div v-if="prescriptionInfo.refund_info && prescriptionInfo.refund_info.length>0">
                  <el-col class="item-left" :span="8">拒绝开方原因</el-col>
                  <el-col class="item-right" :span="16">{{prescriptionInfo.refund_info}}</el-col>
                </div>
              </el-row>
            </el-col>
          </el-row>
        </div>
      </div>
    </div>

    <!--<div class="secondConten">
      <div class="contenBottem ">
        <div class="title" style="margin-bottom: 20px;">处方信息</div>
        <el-table :data="[orderDetailList.prescription_info]" :header-cell-style="{background:'#eef1f6',color:'#606266'}"
                  border style="width: 100%;">
          <el-table-column align="center" prop="user_drug_Info.patientName" label="用药人真实姓名" />
          <el-table-column align="center" prop="user_drug_Info.patientSex_name" label="性别" />
          <el-table-column align="center" prop="user_drug_Info.patientAge" label="年龄" />
          <el-table-column align="center" prop="user_drug_Info.patientWeight" label="体重" />
          <el-table-column align="center" prop="user_drug_Info.patientPhone" label="手机号" />
          <el-table-column align="center" prop="user_drug_Info.patientIdcard" label="身份证" />
          <el-table-column align="center" prop="user_drug_Info.patientBirthday" label="出生日期" />
          <el-table-column align="center" prop="user_drug_Info.patientAddress" label="地址" />
          <el-table-column align="center" prop="checkDoctorName" label="初审医师" />
          <el-table-column align="center" prop="reviewDoctorName" label="复审医师" />
        </el-table>
        <el-table :data="[orderDetailList.prescription_info]" :header-cell-style="{background:'#eef1f6',color:'#606266'}"
                  border style="width: 100%;margin-top: 10px;">
          <el-table-column align="center" prop="status" label="是否有处方单">
            <template slot-scope="scope">
              <div v-if="scope.row.has_prescription==0">否</div>
              <div v-if="scope.row.has_prescription==1">是</div>
            </template>
          </el-table-column>
          <el-table-column v-if="orderDetailList.prescription_info.has_prescription==1" align="center" prop="status" label="处方单">
            <template slot-scope="scope">
              <el-image  v-for="(item,index) in scope.row.prescription_img_list" :key="index" :src="item.img_url" alt="" style="width: 60px;height: 60px;margin-right: 8px;margin-bottom: 10px"></el-image>
            </template>
          </el-table-column>
          <el-table-column v-if="orderDetailList.prescription_info.has_prescription==0" align="center" prop="status" label="审核状态"></el-table-column>
          <el-table-column v-if="orderDetailList.prescription_info.has_prescription==0" align="center" label="疾病名称">
            <template slot-scope="scope">
              <div>{{scope.row.prescription_disease_list}}</div>
            </template>
          </el-table-column>
          <el-table-column v-if="orderDetailList.prescription_info.has_prescription==0" align="center" prop="diagnoseDescription" label="患者主述/健康信息" />
        </el-table>
      </div>
    </div>-->

    <!-- secondStart-->
    <div class="secondConten">
      <div class="contenBottem ">
        <div class="title" style="margin-bottom: 20px;">子订单信息</div>
        <div class="detailAll" :style="'justify-content:'+(number==0?'space-around':'flex-start')">
          <el-table :data="order_item_list" :header-cell-style="{background:'#eef1f6',color:'#606266'}"
            border style="width: 100%;">
            <el-table-column align="center" prop="id" label="序号" />
            <el-table-column align="center" prop="item_num" label="子订单号" />
            <el-table-column align="center" prop="goods_info.name" label="图片" >
              <template slot-scope="scope">
                  <div><img width="50%" :src="thumb_url[0].img_Url"/></div>
              </template>
            </el-table-column>
            <el-table-column align="center" prop="goods_info.upc" label="UPC码" />
            <el-table-column align="center" prop="goods_info.name" label="商品名称" />
            <el-table-column align="center" prop="goods_info.specification" label="规格" />
            <!-- <el-table-column align="center" prop="item_num" label="规格编码" /> -->
            <el-table-column align="center" prop="goods_info.classify_name" label="商品分类" />
            <el-table-column align="center" prop="discount_price" label="单价" />
            <el-table-column align="center" prop="num" label="数量" />
            <el-table-column align="center" prop="discount_amount" label="优惠信息">
               <template slot-scope="scope">
                 <!--<div v-if="scope.row.discount_amount==0">无</div>
                 <div v-else>{{scope.row.discount_amount}}</div>-->
                 <div>{{orderDetailList.coupon_name?orderDetailList.coupon_name:'无'}}</div>
               </template>
            </el-table-column>
            <el-table-column align="center" prop="total_amount" label="总价" />
          </el-table>

          <!-- v-for end-->
        </div>
        <div style="text-align: right;padding: 20px;color: #000000;">实付款：<span style="color: red;">￥{{orderDetailList.pay_amount}}</span></div>
        <div style="display: flex;justify-content: flex-end;color: #b9afaf;font-size: 15px;">
            <div style="margin-right: 20px;">含邮费：{{orderDetailList.delivery_fee}}</div>
            <div style="">优惠金额：{{orderDetailList.coupon_reduce_price}}</div>
        </div>
      </div>
    </div>

    <!-- 退款模态款 -->
    <el-dialog title="退款" style="margin-top: 16vh !important;" :visible.sync="refundDialog">
      <div class="msgDiv">
        <!-- <h3>店铺基础信息</h3> -->
        <div>
          <el-form ref="form" label-width="160px">
            <el-form-item label="退款金额">
              <el-input type="number" v-model="refund.refund_amount"></el-input>
            </el-form-item>
            <el-form-item label="退款原因">
              <el-input type="textarea" v-model="refund.reason" placeholder="退款原因，选填"></el-input>
            </el-form-item>
          </el-form>
          <div v-if="isShowRefundTip" style="text-align: center;color: red;padding-bottom: 15px">全额退款即视为取消订单</div>

          <el-button type="success" :loading="refundBtnLoading" @click="orderRefund()">退款</el-button>
          <el-button v-if="refundType==='apply'" type="danger" @click="orderRefund('no')">不同意</el-button>
        </div>
      </div>
    </el-dialog>

    <!-- 添加模态款 -->
    <el-dialog title="设置发货信息" style="margin-top: 16vh !important;" :close-on-click-modal="false" :visible.sync="modelMsg">
      <div class="msgDiv">
        <!-- <h3>店铺基础信息</h3> -->
        <div>
          <el-form label-width="160px">
            <el-form-item label="订单序号">
              <el-input v-model="expressList.order_id" disabled></el-input>
            </el-form-item>
            <el-form-item label="快递公司/配送平台" :required="true">
              <el-input v-model="expressList.express" placeholder="请填写快递公司/配送平台"></el-input>
            </el-form-item>
            <el-form-item label="快递单号/配送单号" :required="true">
              <el-input v-model="expressList.express_num" placeholder="请填写快递单号/配送单号"></el-input>
            </el-form-item>

          </el-form>
          <div style="text-align: center;">
            <el-button type="success" @click="submitGoods(1)">直接发货</el-button>
            <el-button type="infor" @click="submitGoods(0)">保存草稿</el-button>
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 添加模态款 -->
    <el-dialog title="人工处理" :visible.sync="manualDialog">
      <image-drag
        :picList="prescriptionImg"
        :multiple="true"
        :tipShow="false"
        :action="()=> {return this.$api.UPLOAD_IMG}"
        :on-error="uploadError"
        :on-success="handleSuccess"
        @update="updateFile">
      </image-drag>
      <el-button style="margin-top: 20px" type="primary" @click="setOrderPrescriptionInfo">保存</el-button>
    </el-dialog>
  </div>
</template>

<script>
  import ElImageViewer from "element-ui/packages/image/src/image-viewer"
  import imageDrag from "../../shopManage/compoents/image-drag"
  export default {
    name: "detail",
    components: { ElImageViewer,'image-drag': imageDrag },
    data() {
      return {
        order_id: "",
        orderDetailList: [],
        address_info: [],
        user_info: [],
        order_item_list: [],
        goods_info: [],
        thumb_url:[],
        number:"",
        totalSale:"",
        expressList: {
          order_id: "",
          express: "",
          express_num: "",
          is_shop: ""
        },
        modelMsg: false,
        refundDialog: false,
        refund: {
          order_id: '',
          refund_amount: '',
          reason: ''
        },
        refundType: '',
        refundBtnLoading: false,
        isShowRefundTip: false,
        prescriptionInfo: '',//处方信息
        showViewer: false,
        prescription_img_list: [],
        manualDialog: false,
        prescriptionImg: []
      }

    },
    created() {
      this.order_id = this.$route.query.row
    },
    mounted() {
      this.getOrderDetail()
    },
    watch: {
      //监听相同路由下参数变化的时候，从而实现异步刷新
      $route(to, from) {
        this.order_id = this.$route.query.row;
        this.getOrderDetail()
      }
    },
    methods: {
      //自提确认收货
     async confirmReceive(orderid){
        let params={
          order_id:orderid
        }
        await this.$confirm('确定要确认收货吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '关闭',
          type: 'success'
        }).then(() => {
          const loadingOne = this.$loading({
            lock: true,
            text: '取消中...',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
          })
          this.$api.confirmReceive(params).then(res=>{
            if(res.data.level=="success"){
              this.$message.success(res.data.message)
              this.getOrderDetail()
              loadingOne.close()
            }else{
              this.$message.error(res.data.message)
              loadingOne.close()
            }
          })

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已关闭'
          });
        });

      },
      //直接发货
      submitGoods(is_shop) {
        /* is_shop 为0是保存草稿 , 为1直接发货 */
        this.expressList.is_shop = is_shop
        const loadingOne = this.$loading({
          lock: true,
          text: '保存中...',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        })
        this.$api.setOrderShipInfo(this.expressList).then(res => {
          this.$message({
            type: res.data.level,
            message: res.data.message
          });
          if (res.data.level == "success") {
            window.location.reload()
            this.modelMsg = false
            loadingOne.close()
          } else {
            loadingOne.close()
            this.modelMsg = true
          }

        })
      },
      //打开弹窗
      deliverGoods(row) {
        this.expressList.order_id = row.id
        this.modelMsg = true
        this.expressList.express = row.express
        this.expressList.express_num = row.express_num
        this.expressList.is_shop =""
      },
      //取消订单
      async cancelOrder(id) {
        let params = {
          "order_id": id
        }
        await this.$confirm('确定要取消此订单吗?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '关闭',
          type: 'warning'
        }).then(() => {
          const loadingOne = this.$loading({
            lock: true,
            text: '取消中...',
            spinner: 'el-icon-loading',
            background: 'rgba(0, 0, 0, 0.7)'
          })
          this.$api.cancelOrder(params).then(res => {
            this.$message({
              type: res.data.level,
              message: res.data.message
            });
            if (res.data.level == "success") {
              this.getOrderDetail()
              loadingOne.close()
            } else {
              loadingOne.close()
            }
          })

        }).catch(() => {
          this.$message({
            type: 'info',
            message: '已关闭'
          });
        });

      },
      getOrderDetail() {

        this.$api.getOrderDetail({
          order_id: this.order_id
        }).then(res => {
          this.orderDetailList = res.data.data
          this.totalSale = this.orderDetailList.original_price-this.orderDetailList.discount_price
          this.address_info = this.orderDetailList.address_info
          this.user_info = this.orderDetailList.user_info
          this.order_item_list = this.orderDetailList.order_item_list
          this.order_item_list.forEach(item=>{
              this.number++
          })
          //计算子订单数量是奇数还是偶数
          this.number = this.number%2
          this.goods_info = this.order_item_list[0].goods_info
          this.thumb_url = this.goods_info.thumb_url

          //保存处方信息
          this.prescriptionInfo = this.orderDetailList.prescription_info?this.orderDetailList.prescription_info:{}

        })
      },

      showRefundDialog(item,type) {
        let id = item.id
        let money = item.pay_amount
        let status = item.status
        if ([2, 3].includes(status)) {
          this.isShowRefundTip = true
        } else {
          this.isShowRefundTip = false
        }
        this.refundBtnLoading = false;
        this.refundDialog = true;
        this.refund.order_id = id;
        this.refund.reason = ''
        if(money){
          this.refund.refund_amount = money
        } else{
          this.refund.refund_amount = ''
        }
        this.refundType = type
      },

      //退款
      orderRefund(type) {
        if(type==="no"){
          this.refund.refund_amount = ''
        } else{
          if(!this.refund.refund_amount){
            this.$message.error("请输入退款金额")
            return
          } else if(this.refund.refund_amount==0){
            this.$message.error("退款金额要大于0")
            return
          }
        }
        this.refundBtnLoading = true;
        this.$api.orderRefund({
          order_id: this.refund.order_id,
          refund_amount: this.refund.refund_amount,
          reason: this.refund.reason
        }).then(res => {
          this.refundBtnLoading = false;
          this.$message({
            type: res.data.level,
            message: res.data.message
          });
          if (res.data.level == "success") {
            this.$message.success(res.data.message)
            this.getOrderList()
            this.refundDialog = false
          } else {
            if(res.data.message=="已拒绝"){
              this.getOrderList()
              this.refundDialog = false
            } else{
              this.$message.error(res.data.message)
            }
          }

        })
      },

      checkPrescriptionImg(images) {
       if(images){
         images.forEach(item => {
           this.prescription_img_list.push(item.img_url)
         })
       }
       this.showViewer = true
      },

      closeImgViewer() {
       this.showViewer = false
      },

      showManualDialog() {
        this.manualDialog = true
      },

      handleSuccess(res, file){
        this.prescriptionImg.push({id: res.data.id,key: file.uid,url: res.data.img_url})
      },
      //上传失败提示
      uploadError() {
        this.$message.error("上传失败，请重新上传");
      },
      updateFile(val) {
        this.prescriptionImg = val
      },

      async setOrderPrescriptionInfo() {
       let imgs = []
        this.prescriptionImg.forEach(item => {
          imgs.push(item.id)
        })
        const res = await this.$api.setOrderPrescriptionInfo({
          prescription_info_id: this.orderDetailList.prescription_info.id,
          prescription_imgs: imgs
        })
        if(res.data.level==="success"){
          this.$message.success(res.data.message)
          this.manualDialog = false
          this.getOrderDetail()
        } else {
          this.$message.error(res.data.message)
        }
      }

    }
  }
</script>
<style scoped lang="scss">
  @import "../../../assets/css/detailCss.scss";
  .msgDiv {
    width: 80%;
    margin: auto;
    text-align: center;
  }


  .prescription-status{
    padding: 15px 0;
    .left{
      font-weight: bold;
    }
    .right{
      margin-left: 20px;
    }
  }

  .prescription-info{
    color: #333333;
    .item-left,.item-right{
      border: 1px solid #EDEDED;
      padding: 0 5px;
      /*line-height: 50px;*/
      /*height: 50px;*/
      min-height: 50px;
      box-sizing: border-box;
      vertical-align: center;
      display: flex;
      align-items: center;
      font-size: 14px;
    }
    .item-left{
      /*font-weight: bold;*/
    }
    .item-right{

    }
  }



</style>
<style scoped>
  /* 图片上传css */
  .avatar-uploader /deep/.el-upload {
    border: 1px dashed #807979;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409EFF;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 100px;
    height: 100px;
    line-height: 100px;
    text-align: center;
  }
  .avatar {
    width: 100px;
    height: 100px;
    display: block;
  }
</style>
